{extend name="base"/}
{block name="resources"}
{/block}
{block name="main"}
<!-- 搜索框 -->
<div class="ns-single-filter-box">
	<div class="layui-form">
		<div class="layui-inline">
			<div class="layui-input-inline">
				<div class="layui-input-inline">
					<input type="text" class="layui-input" placeholder="开始时间" name="start_date" id="start_time" autocomplete="off" readonly>
				</div>
				<div class="layui-input-inline end-item">
					<input type="text" class="layui-input" placeholder="结束时间" name="end_date" id="end_time" autocomplete="off" readonly>
				</div>
			</div>
		</div>
		<div class="layui-input-inline">
			<input type="text" name="search_text" placeholder="请输入店铺名称" autocomplete="off" class="layui-input">
			<button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
				<i class="layui-icon">&#xe615;</i>
			</button>
		</div>
	</div>
</div>

<div class="layui-tab ns-table-tab" lay-filter="status">
	<ul class="layui-tab-title">
		<li class="layui-this" lay-id="">全部</li>
		<li lay-id="0">待审核</li>
		<li lay-id="1">已通过</li>
		<li lay-id="-1">已拒绝</li>
	</ul>
	
	<div class="layui-tab-content">
		<!-- 列表 -->
		<table id="member_account_list" lay-filter="member_account_list"></table>
	</div>
</div>

<!--操作-->
<script type="text/html" id="operation">
	<div class="ns-table-btn">
		<a class="layui-btn" lay-event="basic">查看</a>
	</div>
</script>

<!--时间-->
<script type="text/html" id="times">
	<div class="layui-elip">创建时间：{{ns.time_to_date(d.create_time)}}</div>
    <div class="layui-elip">审核时间：{{ns.time_to_date(d.audit_time)}}</div>
</script>

<!--状态-->
<script type="text/html" id="status">
	{{# if(d.status == 0){ }}
    <div class="layui-elip">待审核</div>
    {{# }else if(d.status == 1){ }}
    <div class="layui-elip">已通过</div>
    {{# }else if(d.status == -1){ }}
    <div class="layui-elip">已拒绝</div>
    {{# } }}
</script>
{/block}

{block name="script"}
<script>
	layui.use(['form', 'laydate', 'element'], function() {
		var table,
			form = layui.form,
			element = layui.element,
			laydate = layui.laydate,
			currentDate = new Date(),
			minDate = "";
		form.render();

		currentDate.setDate(currentDate.getDate() - 7);

		//开始时间
		laydate.render({
			elem: '#start_time',
			type: 'datetime'
		});

		//结束时间
		laydate.render({
			elem: '#end_time',
			type: 'datetime'
		});

		/**
		 * 重新渲染结束时间
		 * */
		function reRender() {
			$("#end_time").remove();
			$(".end-item").html('<input type="text" class="layui-input" placeholder="结束时间" name="end_date" id="end_time" >');
			laydate.render({
				elem: '#end_time',
				type: 'datetime',
				min: minDate
			});
		}
		
		//监听Tab切换
		element.on('tab(status)', function(data) {
			var status = $(this).attr("lay-id");
			table.reload( {
				page: {
					curr: 1
				},
				where: {
					'status': status
				}
			});
		});

		/**
		 * 表格加载
		 */
		table = new Table({
			elem: '#member_account_list',
			url: ns.url("admin/shopaccount/deposit"),
			cols: [
				[{
					field: 'site_name',
					title: '店铺名称',
					width: '15%',
					unresize: 'false',
				}, {
					field: 'money',
					title: '金额',
					width: '10%',
					unresize: 'false',

				}, {
					field: 'pay_account_name',
					title: '银行名称',
					width: '10%',
					unresize: 'false',
					align: 'center',
				}, {
					field: 'remark',
					title: '支付凭据说明',
					width: '15%',
					unresize: 'false',
					align: 'center',
				}, {
					field: 'status',
					title: '状态',
					width: '10%',
					unresize: 'false',
					align: 'center',
					toolbar: '#status'
				}, {
					title: '时间',
					width: '30%',
					unresize: 'false',
					align: 'center',
					toolbar: '#times'
				}, {
					title: '操作',
					width: '10%',
					toolbar: '#operation',
					unresize: 'false'
				}]
			]
		});
		
		/**
		 * 搜索功能
		 */
		form.on('submit(search)', function(data) {
			console.log(data);
			table.reload({
				page: {
					curr: 1
				},
				where: data.field
			});
			return false;
		});

		/**
		 * 监听工具栏操作
		 */
		table.tool(function(obj) {
			var data = obj.data,
				event = obj.event;
            switch (obj.event) {
                case 'basic': //查看
                    location.href = ns.url("admin/shop/accountinfo?site_id=" + data.site_id)
                    break;
            }

		})
	});
</script>
{/block}